﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Portal.Models;

namespace MvcApplication2.Controllers
{
    public class HomeController : CmsController
    {
        public ActionResult Index()
        {
            
            setHeader("Recent Entries");

            ViewData.Model = DB.Pages.Top("5").OrderByDescending(o=>o.Id);
            return View();
            
        }


        public ActionResult Categories()
        {

            setHeader("Categories");

            ViewData.Model = DB.Categories.ToList();
            return View();

        }

        public ActionResult Category(int Id)
        {
            ViewBag.Category = DB.Categories.SingleOrDefault(m => m.Id == Id);
            setHeader(ViewBag.Category.Name);//TODO: prideti keyword'us
            ViewData.Model = DB.Pages.Where(m => m.Category_id == Id);
            
            return View();
        }


    }
}
